home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_08 / plauger / isxint.c < prev    next >
C/C++ Source or Header  |  1994-06-09  |  344b  |  17 lines

  1. -------------------------- Listing 8: int extractor  ---------
  2.  
  3. // isxint -- istream::operator>>(int&)
  4. #include <limits.h>
  5. #include <istream>
  6.  
  7. istream& istream::operator>>(int& i)
  8.     {    // extract an int
  9.     long lo;
  10.     *this >> lo;
  11.     if (!good() || lo < INT_MIN || INT_MAX < lo)
  12.         setstate(failbit);
  13.     else
  14.         i = lo;
  15.     return (*this);
  16.     }
  17.